import request from '@/utils/request'

// 查看商户所有SKU，分页
export function getProjectGoodsList(params) {
  return request({
    url:'/genius/platform-project-goods/list',
    method: 'GET',
    params: params,
  })
}

// 添加SKU
export function addSKU({ skuId = '', skuName = '', userId = 0, imageUrl, classify , biPuPin }) {
  return request({
    url: '/sku/add',
    method: 'post',
    data: { skuId, skuName, userId, imageUrl, classify, biPuPin},
  })
}
//导出excel
export function exportSKUExcel(params){
  return request({
    url:'/genius/platform-goods/export',
    method:'post',
    params
  })
}

// 添加SKU
export function addProjectSKU(params) {
  return request({
    url: `/genius/platform-goods`,
    method: 'post',
    data: params,
    timeout: 60 * 3 * 1000,//超时
  })
}
//获取项目
export function getProjectList(params){
    return request({
        url: 'genius/platform-project/list',
        method: 'get',
        params,
      })
}

export function batchInsert(params){
  return request({
      url: '/genius/platform-project-goods/batchInsert',
      method: 'post',
      data: params,
    })
}
// 修改SKU
export function modifyProjectSKU(params) {
  return request({
    url: `/genius/platform-project-goods`,
    method:'put',
    data: params,
  })
}

//查看项目商品详细信息
export function getProjectGoodsInfo(params) {
  return request({
    url: `/genius/platform-project-goods/${params}`,
    method: 'get',
  })
}




// 删除SKU
export function delProjectSKU({ ids }) {
  return request({
    url:`/genius/platform-project-goods/${ids}`,
    method: 'delete',
    data: { ids },
    params: { ids }
  })
}

// 修改SKU
export function modifySKU({ skuId = '', skuName = '', userId = 0, imageUrl, id, classify , biPuPin }) {
  return request({
    url: '/sku/modify',
    method: 'post',
    data: { skuId, skuName, userId, imageUrl, id, classify, biPuPin },
  })
}

// 上传SKU图片
export function uploadSKUImage({ file, userId }) {
  return request({
    url: '/sku/upload',
    method: 'post',
    data: { file, userId },
  })
}

// 查看模型库上的SKU列表，分页
export function getSKULibList({ pageIndex = 0, pageSize = 20, skuId, skuName }) {
  return request({
    url: '/sku/list-page-lib',
    method: 'GET',
    params: { pageIndex, pageSize, skuId, skuName },
  })
}

// 查看商户所有SKU，分页
export function getUserSKUList(params,{ pageIndex = 0, pageSize = 20, userId , skuName }) {
  return request({
    //url: '/sku/list-page',
    url:'/genius/platform-goods/list',
    method: 'GET',
    params: params,
  })
}

// 绑定模型库skuid
export function bindSKU(bindList) {
  return request({
    url: '/sku/bind',
    method: 'post',
    data: bindList,
  })
}

// 同步算法库
export function syncSKU() {
  return request({
    url: '/sku/syncsku',
    method: 'post',
  })
}


// 创建sku组合
export function createSKUCompose({
  list = [],
  name = '',
  remark = '',
  userId = 0,
}) {
  return request({
    url: '/sku/compose/create',
    method: 'post',
    data: { list, name, remark, userId },
  })
}

// 删除SKU组合
export function delSKUCompose(id) {
  return request({
    url: '/sku/compose/delete',
    method: 'post',
    params: { id },
  })
}

// 查看所有sku组合
export function getSKUCompose(params) {
  return request({
    url: '/sku/compose/list',
    method: 'get',
    params,
  })
}

// 编辑sku组合
export function modifySKUCompose({
  id = 0,
  list = [],
  name = '',
  remark = '',
  userId = 0,
}) {
  return request({
    url: '/sku/compose/modify',
    method: 'post',
    data: { id, list, name, remark, userId },
  })
}



// 查看用户的必铺品数据
export function getBiPuPin(params) {
  return request({
    url: '/sku/list-bipupin',
    method: 'GET',
    params
  })
}

// 批量新增主设备
export function batchDevice(params) {
  const { file } = params
  return request({
    url: `/devices/register-batch`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    method: 'post',
    data: file,
    timeout: 60 * 3 * 1000,
  })
}
